Color Class

A Color is an intrinsic data type that consists of three bytes that define the color. A color can be set using the RGB, HSV, or CMY models or the &c literal.

Events

None

Properties

Blue

Red

Cyan

Saturation

Green

Value

Hue

Yellow

Magenta

 

Methods

None

Each set of properties is used with the appropriate function to specify a color. The values of any of the nine properties can then be read. The default value of a Color is &c000000 (white).


Notes

Colors are often used to assign colors to properties of type Color. Use the RGB, HSV, or CMY functions to assign a color to an object or use the format:

&cRRGGBB

where RR is the RGB value of Red in hexadecimal, GG is the value Green in hexadecimal, and BB is the value of Blue in hexadecimal. You can choose the color that you want to assign to a property by clicking on the existing color in the Properties pane to open the Color picker. Choose the color via the Color picker and REALbasic will figure out the hexadecimal values that represent that color.

You can use the VarType function to determine whether a property or a variable is a Color. If it is, VarType returns 16.


Examples

The following example uses the RGB model to set the forecolor property of a Canvas control and draw a square using the current forecolor. The code is placed in the Canvas control's Paint event.

Canvas1. Graphics.foreColor= RGB(255,0,0)
Canvas1. Graphics.drawrect 0,0,50,50

The following example assigns a color directly using the RGB color model. The RGB values must be specified in hexadecimal:

Canvas1. Graphics.foreColor= &cFF0000
Canvas1. Graphics.drawrect 0,0,50,50

The following example uses the CMY model to set the fillcolor of a Rectangle control, r.

r.fillColor= CMY(.1,.3,.5)

The following example inverts the fillcolor:

Dim c as Color
c=RGB(255-r.fillcolor.red,255-r.fillcolor.green, 255-r.fillColor.blue)
r.fillColor=c

See Also

CMY, DarkTingeColor, FillColor, FrameColor, HighlightColor, HSV, LightBevelColor, LightTingeColor, RGB, SelectColor, TextColor, Variant, VarType functions; &c literal; Dim statement.